<include file="Public/min-header"/>
<div class="wrapper">
  <include file="Public/breadcrumb"/>
	<section class="content">
       <div class="row">
       		<div class="col-xs-12">
	       		<div class="box">
	           	<div class="box-header">
	               <nav class="navbar navbar-default">	     
				        <div class="collapse navbar-collapse">
				            <div class="navbar-form row">
					            <a href="{:U('Version/add',['platform'=>1])}" class="btn btn-primary pull-right" data-toggle='tooltip'data-original-title="新增iOS版本"><i class="fa fa-plus" ></i>新增iOS版本</a>
					            <a href="{:U('Version/add',['platform'=>2])}" class="btn btn-primary pull-right" data-toggle='tooltip'data-original-title="新增Android版本"><i class="fa fa-plus" ></i>新增Android版本</a>
				            </div>
				      	</div>
					</nav>
					<ul class="nav nav-tabs">
						<foreach name="platform" key="k" item="vo">
							<li <if condition="$k eq $platform_set">class="active"</if>>
								<a href="{:U('Version/index',array('platform'=>$k))}">
									<if condition="$k eq 0">
										所有
										<else/>
										{$vo}
									</if>
								</a>
							</li>    
						</foreach>
						                 
					</ul>          
	             </div>	    
	             <!-- /.box-header -->
	             <div class="box-body">	             
	           		<div class="row">
	            	<div class="col-sm-12">
		              <table id="list-table" class="table table-bordered table-striped dataTable" role="grid" aria-describedby="example1_info">
		                 <thead>
		                   <tr role="row">
			                   <th class="sorting" tabindex="0">版本号</th>
			                   <th class="sorting" tabindex="0">名称</th>
			                   <th class="sorting" tabindex="0">平台</th>
                               <th class="sorting" tabindex="0">状态</th>
                               <th class="sorting" tabindex="0">版本更新提示</th>
                               <th class="sorting" tabindex="0">强制更新的最新版本</th>
			                   <th class="sorting" tabindex="0">创建时间</th>
			                   <th class="sorting" tabindex="0">发布时间</th>
			                   <th class="sorting" tabindex="0">操作</th>
		                   </tr>
		                 </thead>
						<tbody>
						  <foreach name="list" item="vo" key="k" >
						  	<tr role="row" align="center">
		                     <td>{$vo.app_ver}</td>
		                     <td>{$vo.app_ver_name}</td>
		                     <td>{$platform[$vo['platform']]}</td>
		                     <td>{$status[$vo['status']]}</td>
		                     <td>{$vo.update_tissue}</td>
		                     <td>{$vo.last_need_update_ver}</td>
		                     <td>{$vo.create_time}</td>		                     
		                     <td>{$vo.publish_time}</td>		                     
		                     <td>
		                     
                              
                              	<if condition="$vo.status eq 0">
									<a class="btn btn-primary" href="{:U('Version/add',array('id'=>$vo['id']))}" data-toggle='tooltip' data-original-title="修改" ><i class="fa fa-pencil"></i></a>
                                	<a class="btn btn-success" href="javascript:void(0)" data-url="{:U('Version/publish')}" data-id="{$vo.id}" onclick="publish(this)" data-toggle='tooltip' data-original-title="发布"><i class="fa fa-save"></i></a>
									<a class="btn btn-danger" href="javascript:void(0)" data-url="{:U('Version/del')}" data-id="{$vo.id}" onclick="delfun(this)" data-toggle='tooltip' data-original-title="删除"><i class="fa fa-trash-o"></i></a>
								</if>
                              
                              
                            </td>
		                   </tr>
		                  </foreach>
		                   </tbody>
		                 <tfoot>
		                 
		                 </tfoot>
		               </table>
	               </div>
	          </div>
              <div class="row">
              	    <div class="col-sm-6 text-left"></div>
                    <div class="col-sm-6 text-right">{$page}</div>		
              </div>
	          </div><!-- /.box-body -->
	        </div><!-- /.box -->
       	</div>
       </div>
   </section>
</div>
<script>
function delfun(obj){
	if(confirm('确认删除')){		
		$.ajax({
			type : 'post',
			url : $(obj).attr('data-url'),
			data : {act:'del',id:$(obj).attr('data-id')},
			dataType : 'json',
			success : function(data){
				if(data){

                    if(data.status==0)
                    {
                        return layer.alert(data.info, {icon: 2});  //alert('删除失败');
                    }
					return $(obj).parent().parent().remove();
				}else{
					layer.alert('删除失败', {icon: 2});  //alert('删除失败');
				}
			}
		})
	}
	return false;
}
function publish(obj){
	if(confirm('确认发布')){		
		$.ajax({
			type : 'post',
			url : $(obj).attr('data-url'),
			data : {act:'publish',id:$(obj).attr('data-id')},
			dataType : 'json',
			success : function(data){
				if(data){

                    if(data.status==0)
                    {
                        return layer.alert(data.info, {icon: 2});  //alert('删除失败');
                    }
					return window.location = document.URL;
				}else{
					layer.alert('删除失败', {icon: 2});  //alert('删除失败');
				}
			}
		})
	}
	return false;
}
</script>  
</body>
</html>